﻿/*
 * Copyright 2010 Pieter De Rycke
 *
 * This file is part of Frozen Bubble XNA.
 *
 * Frozen Bubble XNA is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2, as published by the Free Software Foundation.
 *
 * Frozen Bubble XNA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with Frozen Bubble XNA. If not, see 
 * <http://www.gnu.org/licenses/>.
 *
 * Artwork:
 *    Alexis Younes <73lab at free.fr>
 *      (everything but the bubbles)
 *    Amaury Amblard-Ladurantie <amaury at linuxfr.org>
 *      (the bubbles)
 *
 * Soundtrack:
 *    Matthias Le Bidan <matthias.le_bidan at caramail.com>
 *      (the three musics and all the sound effects)
 *
 * Design & Programming:
 *    Guillaume Cottenceau <guillaume.cottenceau at free.fr>
 *      (design and manage the project, whole Perl sourcecode)
 *
 * XNA and Windows Phone 7 port:
 *    Pieter De Rycke
 *
 * Websites:
 *    http://www.frozen-bubble.org/
 *    http://pieterderycke.wordpress.com/
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace FrozenBubble
{
    public class MenuEntry
    {
        internal MenuEntry() { }

        public MenuEntry(string text, Vector2 position, Texture2D image, Texture2D hoverOver)
        {
            Text = text;
            Position = position;
            Image = image;
            HoverOver = hoverOver;
            Texture = image;
        }

        public MenuEntry(string text, Vector2 position, Texture2D image, Texture2D hoverOver, bool selected)
            : this(text, position, image, hoverOver)
        {
            if (selected)
                Texture = HoverOver;
            else
                Texture = image;
        }

        public Texture2D Image { get; protected set; }
        public Texture2D HoverOver { get; protected set; }
        public string Text { get; protected set; }
        public Vector2 Position { get; protected set; }
        public Texture2D Texture { get; protected set; }
        public bool IsSelected { get; protected set; }

        /// <summary>
        /// Event raised when the menu entry is clicked.
        /// </summary>
        public event EventHandler<EventArgs> Click;

        internal virtual void DoClick(object sender)
        {
            if (Click != null)
            {
                Click(sender, EventArgs.Empty);
            }
        }

        internal virtual void DoHover(object sender)
        {
            Texture = HoverOver;
        }

        internal virtual void DoUnHover(object sender)
        {
            Texture = Image;
        }
    }
}
